package org.ssmd3.service.impl;

import org.springframework.stereotype.Service;
import org.ssmd3.dao.NewsTypeMapper;
import org.ssmd3.pojo.NewsType;
import org.ssmd3.service.NewsTypeService;

import javax.annotation.Resource;
import java.util.List;

@Service("newsTypeService")
public class NewsTypeServiceImpl implements NewsTypeService {

    @Resource
    NewsTypeMapper newsTypeMapper;

    @Override
    public int save(NewsType newsType) {
        if (newsType.getParentId().equals(0)){
            newsType.setParentId(null);
        }
        return newsTypeMapper.save(newsType);
    }

    @Override
    public int update(NewsType newsType) {
        if (newsType.getParentId().equals(0)){
            newsType.setParentId(null);
        }
        return newsTypeMapper.update(newsType);
    }

    @Override
    public NewsType getOneNewsType(int id) {
        return newsTypeMapper.getOneNewsType(id);
    }

    @Override
    public int getRecordCount(NewsType newsType) {
        return newsTypeMapper.getRecordCount( newsType);
    }
    @Override
    public List<NewsType> getNewsTypeListByPage(NewsType newsType) {
        return newsTypeMapper.getNewsTypeListByPage(newsType);
    }

    @Override
    public List<NewsType> getTopNewsTypeList() {
        return newsTypeMapper.getTopNewsTypeList();
    }

    @Override
    public List<NewsType> getAllNewsTypeList() {
        return newsTypeMapper.getAllNewsTypeList();
    }

    @Override
    public int delete(int id) {
        return newsTypeMapper.delete(id);
    }

    @Override
    public int deleteAll(String[] ids) {
        return newsTypeMapper.deleteAll(ids);
    }


}
